<?php
session_start();
require_once "elements/sqlconnect.php";
require_once "elements/functions.php";
require_once "elements/sqlFunctions.php";
$sitetitle = "The Moviebase";
$outputhead = "";
$outputcontent = "";
$outputfoot = "";


$outputhead .= '
	<!-- Menu -->
	
	<table class="menu" cellpadding="0" cellspacing="0" width="100%">
		<tr>
			<th><a href="index.php?site=index">Home</a></th>';
if(isset($_SESSION['loggedin'])){
	if($_SESSION['loggedin']){
		$outputhead .= ' <th><a href="index.php?site=usercenter">Usercenter</a></th> ';
		$outputhead .= ' <th><a href="index.php?site=logout">Logout</a></th> ';
	}else{
		$outputhead .= ' <th><a href="index.php?site=login">Login</a></th> ';
	}
}else{
	$outputhead .= ' <th><a href="index.php?site=login">Login</a></th> ';
}

$outputhead .= '
		</tr>
	</table>';


if(!empty($_GET["site"])){
	if(file_exists("sites/".$_GET["site"].".php")){
		$filename =  "sites/".$_GET["site"].".php";
		$sitetitle = ucfirst($_GET["site"]);
	}else{
		$filename =  "sites/index.php";
	}
}else{
	$filename =  "sites/index.php";
}

add_headline($outputhead,$sitetitle);
add_footer($outputfoot);

//Output
echo $outputhead;
include $filename;
echo $outputcontent;
echo $outputfoot;
?>
